<f:view xmlns:h="http://java.sun.com/jsf/html"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:fn="http://java.sun.com/jsp/jstl/functions"
        xmlns:g="http://code.google.com/p/ada-ado/generator"
        xmlns:f="http://java.sun.com/jsf/core"
        file="#{projectName}-applications.adb">-----------------------------------------------------------------------
--  #{projectName} -- #{projectName} applications
-----------------------------------------------------------------------
<ui:include src="../../licenses/license-ada.xhtml"/>
-----------------------------------------------------------------------
#{''}
with Ada.IO_Exceptions;
#{''}
with Util.Log.Loggers;
with Util.Properties;
#{''}
with ASF.Applications;
with ASF.Applications.Main;
with ASF.Applications.Main.Configs;
#{''}
with AWA.Applications.Factory;
#{''}
--  with #{fn:capitalize(projectName)}.XXX.Module;
package body #{fn:capitalize(projectName)}.Applications is
#{''}
   use AWA.Applications;
#{''}
   Log     : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("#{fn:capitalize(projectName)}");
#{''}
   --  ------------------------------
   --  Initialize the application:
   --  &lt;ul&gt;
   --     &lt;li&gt;Register the servlets and filters.
   --     &lt;li&gt;Register the application modules.
   --     &lt;li&gt;Define the servlet and filter mappings.
   --  &lt;/ul&gt;
   --  ------------------------------
   procedure Initialize (App : in Application_Access) is
      Fact  : AWA.Applications.Factory.Application_Factory;
      C     : ASF.Applications.Config;
   begin
      App.Self := App;
      begin
         C.Load_Properties ("#{projectName}.properties");
         Util.Log.Loggers.Initialize (Util.Properties.Manager (C));
#{''}
      exception
         when Ada.IO_Exceptions.Name_Error =>
            Log.Error ("Cannot read application configuration file {0}", CONFIG_PATH);

      end;
      App.Initialize (C, Fact);
#{''}
      App.Set_Global ("contextPath", CONTEXT_PATH);
   end Initialize;
#{''}
   --  ------------------------------
   --  Initialize the servlets provided by the application.
   --  This procedure is called by <b>Initialize</b>.
   --  It should register the application servlets.
   --  ------------------------------
   overriding
   procedure Initialize_Servlets (App : in out Application) is
   begin
      Log.Info ("Initializing application servlets...");
#{''}
      AWA.Applications.Application (App).Initialize_Servlets;
      App.Add_Servlet (Name => "faces", Server => App.Self.Faces'Access);
      App.Add_Servlet (Name => "files", Server => App.Self.Files'Access);
      App.Add_Servlet (Name => "ajax", Server => App.Self.Ajax'Access);
      App.Add_Servlet (Name => "measures", Server => App.Self.Measures'Access);
      App.Add_Servlet (Name => "auth", Server => App.Self.Auth'Access);
      App.Add_Servlet (Name => "verify-auth", Server => App.Self.Verify_Auth'Access);
   end Initialize_Servlets;
#{''}
   --  ------------------------------
   --  Initialize the filters provided by the application.
   --  This procedure is called by <b>Initialize</b>.
   --  It should register the application filters.
   --  ------------------------------
   overriding
   procedure Initialize_Filters (App : in out Application) is
   begin
      Log.Info ("Initializing application filters...");
#{''}
      AWA.Applications.Application (App).Initialize_Filters;
      App.Add_Filter (Name => "dump", Filter => App.Dump'Access);
      App.Add_Filter (Name => "measures", Filter => App.Measures'Access);
      App.Add_Filter (Name => "service", Filter => App.Service_Filter'Access);
   end Initialize_Filters;
#{''}
   --  ------------------------------
   --  Initialize the AWA modules provided by the application.
   --  This procedure is called by <b>Initialize</b>.
   --  It should register the modules used by the application.
   --  ------------------------------
   overriding
   procedure Initialize_Modules (App : in out Application) is
   begin
      Log.Info ("Initializing application modules...");
#{''}
      Register (App    => App.Self.all'Access,
                Name   => AWA.Users.Modules.NAME,
                URI    => "user",
                Module => App.User_Module'Access);
#{''}
      Register (App    => App.Self.all'Access,
                Name   => AWA.Workspaces.Modules.NAME,
                URI    => "workspaces",
                Module => App.Workspace_Module'Access);
#{''}
      Register (App    => App.Self.all'Access,
                Name   => AWA.Mail.Modules.NAME,
                URI    => "mail",
                Module => App.Mail_Module'Access);
#{''}
      Register (App    => App.Self.all'Access,
                Name   => AWA.Comments.Modules.NAME,
                URI    => "comments",
                Module => App.Comment_Module'Access);
#{''}
      Register (App    => App.Self.all'Access,
                Name   => AWA.Tags.Modules.NAME,
                URI    => "tags",
                Module => App.Tag_Module'Access);
#{''}
      Register (App    => App.Self.all'Access,
                Name   => AWA.Storages.Modules.NAME,
                URI    => "storages",
                Module => App.Storage_Module'Access);
#{''}
      Register (App    => App.Self.all'Access,
                Name   => AWA.Blogs.Modules.NAME,
                URI    => "blogs",
                Module => App.Blog_Module'Access);
   end Initialize_Modules;
#{''}
end #{fn:capitalize(projectName)}.Applications;
</f:view>